package com.jiangds.open.check.checker;

import com.jiangds.open.check.Checker;

import java.math.BigDecimal;

/**
 * {@link DecimalChecker} 金额比较
 *
 * @author jiangliang
 * @since 2021/1/11 9:14
 */
public class DecimalChecker extends AbstractChecker<BigDecimal,BigDecimal> {

    public DecimalChecker(BigDecimal target) {
        super(target);
    }

    @Override
    public Checker<BigDecimal, BigDecimal> notEmpty() {
        return notNull();
    }

    @Override
    public Checker<BigDecimal, BigDecimal> range(BigDecimal min, BigDecimal max) {
        return processor(t->min.compareTo(t)<=0 && max.compareTo(t)>=0);
    }

    @Override
    public Checker<BigDecimal, BigDecimal> greater(BigDecimal greaterThan) {
        return processor(t->t.compareTo(greaterThan)>=0);
    }

    @Override
    public Checker<BigDecimal, BigDecimal> less(BigDecimal lessThan) {
        return processor(t->t.compareTo(lessThan)<=0);
    }

    @Override
    public Checker<BigDecimal, BigDecimal> in(BigDecimal... args) {
        return inProcessor(BigDecimal::equals,args);
    }
}
